﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DNASequencing.core.data.simple;

namespace DNASequencing.core.data.complex
{
    /// <summary>
    /// Data Tree, that has followers in every node.
    /// </summary>
    class ComplexDT : ADataTree
    {
        /// <summary>
        /// Creates new complex data tree.
        /// </summary>
        /// <param name="inputData">List of oligonucleotides as strings.</param>
        public ComplexDT(List<String> inputData)
        {
            _nRoot = new Node();
            _lsAll = new List<AOligonucleotide>();

            foreach (String sequence in inputData)
            {
                Oligonucleotide temp = new Oligonucleotide(sequence);
                _lsAll.Add(temp);
            }

            update();
        }

        public ComplexDT(List<DNASequencing.core.Algorithms.Oligonucleotide> inputData)
        {
            _nRoot = new Node();
            _lsAll = new List<AOligonucleotide>();

            foreach (DNASequencing.core.Algorithms.Oligonucleotide o in inputData)
            {
                Oligonucleotide temp = new Oligonucleotide(o.originalSequence);
                _lsAll.Add(temp);
            }

            update();
        }

        private void update()
        {
            foreach (Oligonucleotide o in all)
            {
                o.updateNext(_lsAll);
                _nRoot.add(o);
            }
        }
    }
}
